﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using Htss.Platform.Web;
using Htss.Platform.Data;
namespace DreamBox.Web.Box.posts
{
    public class readBox:ControllerBox
    {
        public ActionResult Load()
        {
            int postsid = Htss.Platform.Core.Transform.GetInt(Request.RequestContext.RouteData.Values["id"].ToString(), 0);

            DAL.Posts.PostsClass pc = new DAL.Posts.PostsClass();
            //if (!pc.IsRead(int.Parse(Session["GID"].ToString()), postsid))
            //{
            //    BLL.Message.Jump(this, "您没有浏览此文章的权限!", "/", "0");
            //}

            int p = Request.QueryString["p"] != null ? Htss.Platform.Core.Transform.GetInt(Request.QueryString["p"], 0) : 1;
            //计算楼层
            DreamBox.BLL.Posts.ItemIndex.Index = (p - 1) * 10 + 1;
            //更新加载次数
            if (p == 1)
            {
                DAL.Posts.Posts topic = new DAL.Posts.Posts();
                topic.UpdateClick(postsid);
            }
            DbTable dt = new DreamBox.DAL.PSelect().SelectForReader("dbox_v_posts", "*", "PostsID=" + postsid);
            //查询文字(主题)数据
            ViewDbTable["TopicData"] = dt;
            ViewData["Title"] = dt.Rows[0]["Title"];
            ViewData["PostsID"] = dt.Rows[0]["PostsID"];
            //查询文字数据 
            DAL.GetPager page = new DAL.GetPager();
            ViewDbTable["ListData"] = page.GetPageData(p, "dbox_v_replyposts", "ReplyID", "PostsID=" + postsid, 0);

            ViewData["ListPage"] = page.GetPage(p, "PostsID=" + postsid, "dbox_v_replyposts", "ReplyID", "/posts/read/" + postsid)[0];
            return View("posts_read");
        }
    }
}
